<template>
  <Card class="page-fill" style="height:900px">
    <div class="table-data" style="">
      <Table  border :columns="tableColumns" :data="tableDatas"></Table>
    </div>
  </Card>
</template>
<script>
export default {
  data () {
    return {
      tableColumns: [
        {
          type: 'index',
          title: '序号'
        },
        {
          title: '名称',
          key: 'file_name'
        },
        {
          title: '路径',
          key: 'file_path'
        },
        {
          title: '操作',
          render: (h, param) => {
            const vm = this
            return h('div', {}, [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  fontSize: '12px'
                },
                on: {
                  click: () => {
                    vm.create_file(param.row.file_name)
                  }
                }
              }, '加载')
            ])
          }
        }
      ],
      tableDatas: []
    }
  },

  created () {
    this.$ajax = this.$util.ajax()
    this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/manager/service/queryfile', {}).then(re => {
      this.tableDatas = []
      var datas = re.data.data || []
      datas.forEach(item => {
        var tData = {}
        tData.file_name = item.fileName
        tData.file_path = item.filePath
        this.tableDatas.push(tData)
      })
    }).catch(er => {
    })
  },
  methods: {
    create_file (filePath) { //
      var fileDTO = {}
      fileDTO.filePath = filePath
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/manager/service/create_process', fileDTO).then(re => {
        if (re.data.code === 'success') {
          this.$Message.success('操作成功!')
        } else {
          alert(re.data.data)
        }
      }).catch(er => {
      })
    }
  },
  watch: {
    $route (val) {
    }
  },
  props: {}
}
</script>

<style lang="less">
  .xzqy-page {
    /*@media only screen and (min-width:1366px){
      .bottom-btn button:nth-of-type(1){
        margin-right:70px;
      }
    }
    @media only screen and (min-width:1200px){
      .bottom-btn button:nth-of-type(1){
        margin-right:40px;
      }
    }*/
  }
</style>
